package com.vishu.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ExtractNumbersFromSentence {
	

	public static void main(String args[])
	{
		Pattern pat=Pattern.compile("-?[0-9]+");  // '-' should occur 0 or 1 time & 0-9 should occur atleast one time
		
		Matcher mat=pat.matcher("hi this is -1 and 2 where20 is there after -30");
		
		while(mat.find())
		{
			System.out.println(mat.group());
			
			
		}
		
		
	}

}
